package org.json;

import org.junit.Ignore;
import org.junit.Test;

import static org.junit.Assert.*;

public class RelativeJSONPathTest {

    @Test @Ignore
    public void testWeCanFindElementsWithPathWildcards() throws Exception {
        RelativeJSONPath jsonPath = new RelativeJSONPath(new JSONObject("" +
                "{" +
                "   monkey: {" +
                "       food: {" +
                "           banana: \"Elephant\"" +
                "       }" +
                "   }" +
                "}"
        ));

        assertEquals("Elephant", jsonPath.get("//banana"));
        assertEquals("Elephant", jsonPath.get("monkey//banana"));
        assertEquals("Elephant", jsonPath.get("monkey/food//banana"));
        assertEquals("Elephant", jsonPath.get("//food/banana"));
    }

    @Test @Ignore
    public void returnsAllMatchesWhenMultipleNodesMatchAWildcard() throws Exception {
        RelativeJSONPath jsonPath = new RelativeJSONPath(new JSONObject("" +
                "{" +
                "   monkey: {" +
                "       banana: 9.99" +
                "   }," +
                "   banana: \"sausage\"" +
                "}"
        ));

        assertEquals(new JSONArray("[\"sausage\", 9.99]").toString(), jsonPath.get("//banana").toString());
    }

    @Test @Ignore
    public void handlesJsonArrayWildcards() throws Exception {
        RelativeJSONPath jsonPath = new RelativeJSONPath(new JSONObject("" +
                "{" +
                "   monkey: {" +
                "       banana: [" +
                "           1.0," +
                "           2.0," +
                "           3.0" +
                "       ]" +
                "   }" +
                "}"
        ));

        assertEquals(2.0, jsonPath.get("//banana[2]"));
    }
}
